package com.jackie.easyble.bean

import android.bluetooth.BluetoothGattCharacteristic
import com.sscl.easyble.BleManager
import com.jackie.easyble.App
import com.jackie.easyble.R

data class BluetoothGattCharacteristicWithBoolean(
    var expand: Boolean,
    val bluetoothGattCharacteristic: BluetoothGattCharacteristic
) {
    fun getPropertyString(): String {
        val canRead = BleManager.characteristicCanRead(bluetoothGattCharacteristic)
        val canWrite = BleManager.characteristicCanWrite(bluetoothGattCharacteristic)
        val canNotify = BleManager.characteristicCanNotify(bluetoothGattCharacteristic)
        if (!canRead && !canWrite && !canNotify) {
            return App.instance.getString(R.string.null_)
        }
        val stringBuilder = StringBuilder()
        if (canRead) {
            stringBuilder.append(App.instance.getString(R.string.can_read))
        }
        if (canWrite) {
            stringBuilder.append(App.instance.getString(R.string.can_write))
        }
        if (canNotify) {
            stringBuilder.append(App.instance.getString(R.string.can_notify))
        }
        return stringBuilder.toString()
    }
}